package zuoye0509;

import java.util.Scanner;

public class CarMgrTest {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		CarMgr test = new CarMgr();
		Car v = new Car();
		v.name = "皖A0001";
		v.price = 5000;
		test.addCar(v.name, v.price);
		Car w = new Car();
		w.name = "皖A0007";
		w.price = 2500;
		test.addCar(w.name, w.price);

		while (true) {
			System.out.println("1.新增车辆\t2.查看车辆信息\t3.删除淘汰车\t4.借出车辆\t5.车辆归还\t6.退出系统");
			System.out.println("------------------------------------");
			System.out.print("请选择：");
			int a = in.nextInt();
			if (a == 1) {
				System.out.println("---->新增车辆");
				System.out.print("请输入增加车辆的名称：");
				String newName = in.next();
				System.out.print("请输入增加车辆的价格：");
				double newPrice = in.nextDouble();
				boolean q = test.addCar(newName, newPrice);
				System.out.println(q ? "增加成功" : "名称重复，增加失败");
				System.out.println("------------------------------------");
			} else if (a == 2) {
				test.show();
				System.out.println("------------------------------------");
			} else if (a == 3) {
				System.out.print("请输入要淘汰车辆的名称：");
				String oldName = in.next();
				String p = test.cancelCar(oldName);
				System.out.println(p);
				System.out.println("------------------------------------");
			} else if (a == 4) {
				while (true) {
					System.out.print("请输入要租赁的车辆名称：");
					String borrowCar = in.next();
					System.out.print("请输入要租借得时长(天数)：");
					int borrowDay = in.nextInt();
					if (borrowDay <= 0) {
						System.out.println("请重新输入。");
					} else {
						String y = test.rentCar(borrowCar, borrowDay);
						System.out.println(y);
						break;
					}
				}
				System.out.println("------------------------------------");
			} else if (a == 5) {
				System.out.print("请输入要归还得车辆：");
				String repayCar = in.next();
				String m = test.returnCar(repayCar);
				System.out.println(m);
				System.out.println("------------------------------------");
			} else if (a == 6) {
				break;
			} else if (a <= 0 || a > 6) {
				System.out.println("输入错误，请重新输入");
			}

		}

	}

}
